package org.aceor.mddal.gateway.sqlparser.visitor;

import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
import org.aceor.mddal.common.sqlparser.result.object.Column;

import static org.aceor.mddal.common.sqlparser.result.condition.ComparableUnit.BinaryOperator;

/**
 * Created by lxue on 16/3/21.
 */
public class MysqlInsertVisitor extends AbstractMysqlVisitor {
    @Override
    public boolean visit(final MySqlInsertStatement x) {
        for (int i = 0; i < x.getColumns().size(); i++) {
            getParseContext().addCondition(
                    new Column(x.getColumns().get(i).toString())
                    , createComparableUnit(
                            x.getValues().getValues().get(i),
                            BinaryOperator.EQUIVALENT));
        }
        return super.visit(x);
    }
}
